# -*- coding: utf-8 -*-
import os
import sys 
reload(sys)
sys.setdefaultencoding('utf8')

ResPath = "./png"

def pngquantPng(filePath):
    command = "pngquant --ext .png --quality 70-75 --speed 5 --force " + filePath

    os.system(command)
    pass

def readAllFiles(path):
    files = os.listdir(path)

    for fileName in files:
        filePath = os.path.join(path,fileName)
        if os.path.isdir(filePath):
            readAllFiles(filePath)
        else:
            if filePath[-4:] == ".png":
                pngquantPng(filePath)
            
    pass

if __name__=="__main__":
    readAllFiles(ResPath)